/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022.
 * Description: support nosummary feature
 * Author: maiziyi <maiziyi@huawei.com>
 * Create: 2022-07-14
 */

#include <linux/kernel.h>

#include <linux/slab.h>
#include <linux/mtd/mtd.h>
#include <linux/pagemap.h>
#include <linux/crc32.h>
#include <linux/compiler.h>
#include <linux/vmalloc.h>
#include "nodelist.h"
#include "debug.h"
#include "rtos_nosummary.h"

int jffs2_sum_active_rtos(struct jffs2_sb_info *c)
{
	return c->mount_opts.summary_option ? 1 : 0;
}

unsigned int jffs2_update_nosummary_opts(const struct jffs2_sb_info *c, const struct jffs2_sb_info *new_c)
{
	if (new_c->mount_opts.summary_option == 0)
		return 0;
	return c->mount_opts.summary_option;
}

void jffs2_nosummary_console_out(const struct jffs2_sb_info *c)
{
	if (c->mount_opts.summary_option)
		pr_info("JFFS2 summary is allowed\n");
	else
		pr_info("JFFS2 summary is not allowed\n");
}

unsigned int jffs2_can_mark_obsolete(struct jffs2_sb_info *c)
{
	if (c->mount_opts.summary_option)
		return 0;

#ifndef CONFIG_JFFS2_FS_WRITEBUFFER
	return 1;
#else
	return (c->mtd->flags & (MTD_BIT_WRITEABLE));
#endif
}
